﻿using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using NLog.Web;
using ProtoBuf.Meta;

namespace System
{
    public static class LogExtension
    {
        /// <summary>
        /// 注册NLog
        /// </summary>
        /// <param name="buider"></param>
        /// <param name="configFile"></param>
        public static void RegisterNLog(this WebApplicationBuilder buider, string configFile)
        {
            buider.Services.AddLogging(s =>
            {
                s.AddNLog(configFile);
            });
            buider.Host.UseNLog();
        }

        public static IServiceCollection RegisterNLog(this IServiceCollection service, string configFile)
        {
            service.AddLogging(s =>
            {
                s.AddNLog(configFile);
            });
            return service;
        }

    }
}